<template>
  <view class="box">
    <view class="tou top" :style="'padding-top:' + statusBarHeight1 + 'px'">
      <image
        @click="fanhui"
        class="image1"
        src="https://pic.bangbangtongcheng.com/static/fanhui_bai.png"
      />
      历史记录
    </view>
    <scroll-view scroll-y class="scroll-view" refresher-background="#f5f5f5">
      <view class="center">
        <view class="center_item" v-for="(item, index) in Recommend" :key="index">
          <view style="margin: 20rpx 0" v-if="item.customerName">
            客户姓名:{{ item.customerName }}
          </view>
          <view class="RecordBF" v-if="item.languageDescription">
            <view v-for="(i, j) in item.languageDescription.split('|')" :key="j">
              <recor class="audio" :URL="i"></recor>
            </view>
          </view>
          <view class="kuan">
            <!-- 小程序v-model和：value皆不显示， 目前是不可编辑输入框，所以直接view代替 -->
            <!-- <textarea class="textarea" :value="item.recordDescription" disable auto-height 
							placeholder="历史记录描述历史记录描述…" /> -->
            {{ item.recordDescription }}
          </view>
          <view class="history_image">
            <view v-if="item.recordPicture.length > 0">
              <image
                v-for="(i, j) in item.recordPicture"
                :key="j"
                class="image"
                @tap.stop="ViewImage"
                :data-url="i"
                :src="i"
                mode="aspectFit"
              />
            </view>
            <view
              v-if="item.recordVideo.length > 0"
              class="videoPlay"
              @click.stop="ylvideo(item.recordVideo)"
            >
              <image
                style="width: 100%; height: 100%"
                :src="item.recordVideo + '?vframe/jpg/offset/0'"
                mode="aspectFit"
              ></image>
              <image
                class="images"
                src="https://pic.bangbangtongcheng.com/static/bbcz/mdlb-sp01.png"
              ></image>
            </view>
          </view>
          <view class="time">
            <view class="time_right">
              <image
                class="image"
                @click="del(item.id)"
                src="https://pic.bangbangtongcheng.com/static/bbcz/smkg_del01.png"
                mode=""
              ></image>
              <span>{{ item.createDate }}</span>
            </view>
          </view>
        </view>
        <view v-if="Recommend.length == 0" class="none">
          <image src="https://pic.bangbangtongcheng.com/static/none.png" mode="widthFix" />
          <view>没有更多数据了</view>
        </view>
      </view>
    </scroll-view>
    <view class="zbc" v-if="smkg" style="z-index: 11">
      <view class="shangjia">
        <view class="li_1">确定要删除当前的上门看过？</view>
        <view class="li_2" @click="guan()">取消</view>
        <view class="li_3" @click="dels()">确定</view>
      </view>
    </view>
    <previewImgV ref="previewImgV"></previewImgV>
    <uniBall></uniBall>
  </view>
</template>
<script>
  import permision from '@/js_sdk/wa-permission/permission.js'
  import previewImgV from '@/components/previewImgV.vue'
  import recor from '@/components/recorPlayback/recor.vue'
  //#ifdef H5
  import wxshare from '../../utils/index.js'
  //#endif
  import { mapGetters } from 'vuex'
  export default {
    data() {
      return {
        imgUrl: this.$imgSrc,
        userInfo: uni.getStorageSync('Pduser'),
        id: '',
        Recommend: [],
        index: '',
        smkg: false,
        ids: '',
      }
    },
    computed: {
      ...mapGetters(['userid', 'islogin', 'statusBarHeight1', 'userinfo']),
    },
    components: {
      previewImgV: previewImgV,
      recor: recor,
    },
    onLoad(option) {
      this.id = option.id
      this.index = option.index
      if (option.index == 1) {
        this.smkgFyData()
      } else if (option.index == 3) {
        this.smkgZpData()
      } else {
        this.smkgData()
      }
      /* #ifdef H5 */
      this.jinzhi()
      /* #endif */
    },
    mounted() {},
    methods: {
      guan() {
        this.smkg = false
      },
      dels() {
        console.log(this.index, '2222222222222')
        if (this.index == 2) {
          this.$myRequest
            .post('/api/mobile/vehicleOwner/removeVisited', {
              ids: this.ids,
            })
            .then((res) => {
              uni.showToast({
                title: res.msg,
                icon: 'none',
                mask: true,
              })
              setTimeout(() => {
                this.guan()
                this.Recommend = []
                this.smkgData()
              }, 500)
            })
        } else if (this.index == 3) {
          this.$myRequest
            .post('/api/mobile/personnelOwner/removeVisitedLook', {
              ids: this.ids,
            })
            .then((res) => {
              uni.showToast({
                title: res.msg,
                icon: 'none',
                mask: true,
              })
              setTimeout(() => {
                this.guan()
                this.Recommend = []
                this.smkgZpData()
              }, 500)
            })
        } else {
          this.$myRequest
            .post('/mob/iteration/removeHouseVisited', {
              ids: this.ids,
            })
            .then((res) => {
              uni.showToast({
                title: res.msg,
                icon: 'none',
                mask: true,
              })
              setTimeout(() => {
                this.guan()
                this.Recommend = []
                this.smkgFyData()
              }, 500)
            })
        }
      },
      del(id) {
        this.smkg = true
        this.ids = id
      },
      ylvideo(url) {
        this.$refs.previewImgV.open(url)
      },
      ViewImage(e) {
        // console.log('e-----', e.currentTarget.dataset)
        let image = []
        image.push(e.currentTarget.dataset.url)
        uni.previewImage({
          urls: image,
          current: e.currentTarget.dataset.url,
        })
      },
      // 获取上门看过历史记录数据
      smkgData() {
        let that = this
        this.$myRequest

          .get('/api/mobile/vehicleOwner/getVisitedHistoryByVehicleIdAndUserId', {
            userId: this.userInfo.id,
            vehicleId: this.id,
            businessType: this.index,
          })
          .then((res) => {
            res.visitedHistory.pageList.forEach((v) => {
              v.remarks = JSON.parse(v.remarks)
            })
            this.Recommend = res.visitedHistory.pageList
          })
      },
      smkgFyData() {
        let that = this
        this.$myRequest
          .get('/mob/iteration/queryHouseVisitedHistoryByUserIdAndHouseId', {
            userId: this.userInfo.id,
            houseId: this.id,
          })
          .then((res) => {
            res.visitedHistoryList.pageList.forEach((v) => {
              v.remarks = JSON.parse(v.remarks)
            })
            this.Recommend = res.visitedHistoryList.pageList
          })
      },
      // 招聘历史记录数据
      smkgZpData() {
        let that = this
        this.$myRequest
          .get('/api/mobile/personnelOwner/getVisitedLookHistoryByUserId', {
            userId: this.userInfo.id,
            relatedBusiness: this.id,
            visitType: '1', //类型(1: 招聘,2: 简历)
            pageNo: 1,
            pageSize: 99999,
          })
          .then((res) => {
            this.Recommend = res.visitedHistory.pageList.map((item) => {
              return {
                ...item,
                recordPicture: item.recordPicture.length > 0 ? item.recordPicture.split(',') : [],
              }
            })
          })
      },
      fanhui() {
        uni.navigateBack({
          delta: 1,
        })
      },
      jinzhi() {
        let _this = this
        let param = window.location.href.split('#')[0]
        uni.request({
          method: 'post',
          data: {
            url: param,
          },
          header: {
            'content-type': 'application/x-www-form-urlencoded',
          },
          url: 'https://www.bangbangtongcheng.com/conven//mob/login/getJsTicket.do',
          success(re) {
            _this.jinzhifx(re.data)
          },
        })
      },
      jinzhifx(data) {
        wxshare.config({
          debug: false, //是否打开调试
          appId: data.appId, // 公众号的唯一标识
          timestamp: data.timestamp, // 生成签名的时间戳
          nonceStr: data.nonce, // ，生成签名的随机串
          signature: data.signature, // 签名
          jsApiList: ['hideMenuItems'],
        })
        // 禁止分享
        wxshare.hideMenuItems({
          // 要隐藏的菜单项，只能隐藏“传播类”和“保护类”按钮，所有menu项见附录3
          menuList: [
            'menuItem:share:appMessage',
            'menuItem:share:timeline',
            'menuItem:share:timeline',
            'menuItem:share:qq',
            'menuItem:favorite',
            'menuItem:share:QZone',
            'menuItem:openWithSafari',
          ],
        })
      },
    },
  }
</script>
<style lang="less" scoped>
  .scroll-view {
    height: calc(100vh - var(--status-bar-height) - 10px - 88rpx);
  }

  .tou {
    position: relative;
    width: 100%;
    text-align: center;
    line-height: 88rpx;
    font-size: 36rpx;
    color: #fff;
    background-color: #64b6a8;

    .image1 {
      position: absolute;
      width: 32rpx;
      height: 32rpx;
      // top: 116rpx;
      left: 30rpx;
    }
  }

  .box {
    height: 100vh;
    // background-color: #fff;
  }

  .center {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 30rpx;

    .center_item {
      width: 700rpx;
      border-radius: 22rpx;
      background-color: #fff;
      padding-left: 30rpx;
      margin-bottom: 30rpx;

      .RecordBF {
        display: flex;
        align-items: center;
        flex-flow: row wrap;
        margin-top: 30rpx;

        .audio {
          margin-bottom: 20rpx;
        }

        .iteam {
          width: 140rpx;
          height: 50rpx;
          background-color: #ffffff;
          border-radius: 8rpx;
          border: 1px solid #c4c4c4;
          display: flex;
          align-items: center;
          justify-content: space-evenly;
          margin-right: 20rpx;

          .image {
            width: 24rpx;
            height: 24rpx;
            margin: 0;
          }

          .text {
            font-size: 24rpx;
            font-weight: 400;
            color: #333333;
          }
        }
      }

      .kuan {
        width: 640rpx;
        min-height: 200rpx;
        margin-top: 40rpx;
        border: 1px solid #c9c9c9;
        padding: 10rpx;
        display: flex;
        flex-flow: row wrap;
        word-wrap: break-word;

        .textarea {
          width: 620rpx;
          margin-left: 24rpx;
          margin-top: 14rpx;
          line-height: 50rpx;
          letter-spacing: 2rpx;
          padding-bottom: 50rpx;
          font-size: 24rpx;
        }
      }

      .history_image {
        display: flex;
        align-items: center;
        // justify-content: space-between;
        flex-wrap: wrap;
        margin-top: 20rpx;

        /deep/ uni-image {
          margin-top: 0;
        }

        .image {
          width: 200rpx;
          height: 200rpx;
          margin-right: 20rpx;
          margin-bottom: 20rpx;
        }

        .videoPlay {
          position: relative;
          width: 200rpx;
          height: 200rpx;
          margin-right: 20rpx;
          margin-bottom: 20rpx;

          .images {
            width: 40rpx;
            height: 40rpx;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
          }
        }
      }

      .time {
        display: flex;
        justify-content: flex-end;
        margin-top: 14rpx;
        font-size: 26rpx;
        font-weight: 400;
        color: #999999;
        margin-right: 30rpx;
        margin-bottom: 24rpx;

        .time_right {
          display: flex;
          flex-direction: column;
          justify-content: flex-end;
          align-items: flex-end;

          .image {
            width: 60rpx;
            height: 60rpx;
          }
        }
      }
    }
  }

  .down {
    height: 60rpx;
    line-height: 60rpx;
    // border-top: 2rpx solid #d0d0d0;
    text-align: center;
  }

  .none {
    text-align: center;

    image {
      width: 430rpx;
      margin-bottom: 16rpx;
    }

    view {
      height: 40rpx;
      line-height: 40rpx;
      color: #666;
    }
  }

  .zbc {
    position: fixed;
    width: 100%;
    top: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.3);

    .shangjia {
      position: absolute;
      width: 600rpx;
      height: 300rpx;
      background-color: #fff;
      border-radius: 10rpx;
      top: 30%;
      left: 50%;
      transform: translateX(-50%);

      .li_1 {
        width: 100%;
        font-size: 34rpx;
        font-weight: 600;
        margin-left: 114rpx;
        margin-top: 80rpx;
      }

      .li_2 {
        display: inline-block;
        vertical-align: top;
        width: 160rpx;
        height: 60rpx;
        background: #ffffff;
        border: 2rpx solid #64b6a8;
        border-radius: 37rpx;
        text-align: center;
        line-height: 60rpx;
        color: #64b6a8;
        margin-top: 58rpx;
        margin-left: 118rpx;
      }

      .li_3 {
        display: inline-block;
        vertical-align: top;
        width: 160rpx;
        height: 60rpx;
        background: #64b6a8;
        border-radius: 37rpx;
        text-align: center;
        line-height: 60rpx;
        color: #fff;
        margin-top: 58rpx;
        margin-left: 46rpx;
      }
    }
  }
</style>
